package com.ruoyi.aitcommon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aitcommon.domain.AitZjkConfig;
import com.ruoyi.aitcommon.service.IAitZjkConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中间库配置Controller
 * 
 * @author cli
 * @date 2022-04-25
 */
@RestController
@RequestMapping("/aitcommon/zjkconfig")
public class AitZjkConfigController extends BaseController
{
    @Autowired
    private IAitZjkConfigService aitZjkConfigService;

    /**
     * 查询中间库配置列表
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(AitZjkConfig aitZjkConfig)
    {
        startPage();
        List<AitZjkConfig> list = aitZjkConfigService.selectAitZjkConfigList(aitZjkConfig);
        return getDataTable(list);
    }

    /**
     * 导出中间库配置列表
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:export')")
    @Log(title = "中间库配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AitZjkConfig aitZjkConfig)
    {
        List<AitZjkConfig> list = aitZjkConfigService.selectAitZjkConfigList(aitZjkConfig);
        ExcelUtil<AitZjkConfig> util = new ExcelUtil<AitZjkConfig>(AitZjkConfig.class);
        return util.exportExcel(list, "中间库配置数据");
    }

    /**
     * 获取中间库配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aitZjkConfigService.selectAitZjkConfigById(id));
    }

    /**
     * 新增中间库配置
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:add')")
    @Log(title = "中间库配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AitZjkConfig aitZjkConfig)
    {
        return toAjax(aitZjkConfigService.insertAitZjkConfig(aitZjkConfig));
    }

    /**
     * 修改中间库配置
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:edit')")
    @Log(title = "中间库配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AitZjkConfig aitZjkConfig)
    {
        return toAjax(aitZjkConfigService.updateAitZjkConfig(aitZjkConfig));
    }

    /**
     * 删除中间库配置
     */
    @PreAuthorize("@ss.hasPermi('aitcommon:zjkconfig:remove')")
    @Log(title = "中间库配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aitZjkConfigService.deleteAitZjkConfigByIds(ids));
    }
}
